var Data = {}

// 全部订单数据
var AllData = [{
    OrderNumber: "123",
    WaresCount: "123",
    goodsImg: '../' + imgRoot + "/upload/goods_detail_goods.jpg",
    WaresQty: "限购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售商品",
    CreatedTimeString: "精装版套装",
    ReceiverName: "123",
    BuyerNick: "123",
    BuyerMessage: "123",
    ShopMessage: "123",
    ID: '<p class="shop-order-list-item-details">查看详情<p>'
}];

var Returndata = [{
    OrderNumber: "123",
    WaresCount: "123",
    goodsImg: '../' + imgRoot + "/upload/goods_detail_goods.jpg",
    WaresQty: "限购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售购[近铁百货海外旗舰店]在售商品",
    CreatedTimeString: "精装版套装",
    ReceiverName: "123",
    BuyerNick: "123",
    BuyerMessage: "123",
    ShopMessage: "123",
    ID: '<p class="shop-order-list-item-details">查看详情<p>'
}];


AllDatainit(AllData);

ReturnDatainit(Returndata)













// 打开订单条件选择下拉框
$(".shop-om-cs-item-dd-s").on("click", function () {
    console.log($(this))
    $(this).parent(".shop-om-cs-item-drop-down").toggleClass("shop-om-cs-item-drop-down-open").parents(".shop-om-cs-item").siblings(".shop-om-cs-item").find(".shop-om-cs-item-drop-down").removeClass("shop-om-cs-item-drop-down-open")
});

// 选择订单条件选择下拉框的某一项
$(".shop-om-cs-item-dd-content-item").on("click", function () {
    $(this).parents(".shop-om-cs-item-drop-down").removeClass("shop-om-cs-item-drop-down-open").find(".shop-om-cs-item-dd-s-content").text($(this).text());
});

// 关闭查看详情弹窗
$(".shop-dp-hesder-icon").on("click", function () {
    $(".shop-details-popup").hide();
    $(".shop-return-popup").hide();
});

// 查看详情弹窗切换订单
$(".shop-dp-header-list-item").on("click", function () {
    $(this).addClass("shop-dp-header-list-item-s").siblings(".shop-dp-header-list-item").removeClass("shop-dp-header-list-item-s")
    updatePopupContent()
});

// 查看详情弹窗根据选中的标签页更新内容
function updatePopupContent() {
    $(".shop-dp-content-list-item").eq($(".shop-dp-header-list-item-s").index()).show().siblings(".shop-dp-content-list-item").hide();

}
// 添加分页
var page = new Controller.PageControl();
page.init({
    totalCount: 100,    //总页数
    conter: ".shop-order-management-pagination",    //容器选择器
    nowPage: 1,        //当前页，默认第几页
    // callback: fun,       //点击回调
    // gotoCallBack: fun    //跳转回调
});

// 生成全部订单/退货订单切换下拉框
$("")

var sd = new Controller.DateSelect({
    content:".shop-order-switching",
    event:"click",
    // callback:fun(selected){},
    list:[{name:"全部订单",value:"全部订单"},{name:"退款订单",value:"退款订单"}]
});




// 退货订单表格生成函数
function ReturnDatainit(data) {
    Controller.GridControl.Bind(data, ".shop-return-order-list", {
        OrderNumber: {
            cnName: '<p class="shop-all-header-item shop-order-list-col1">交易号</p>',
            index: 0,
            width: '114px',
            converter: function (val, romObj) {
                return `<div class="shop-order-list-col1">` + val + `</div>`
            }
        },
        WaresCount: {
            cnName: '<p class="shop-all-header-item">订单号</p>',
            index: 1,
            width: '124px',
            converter: function (val, romObj) {
                console.log(romObj);
                return `<div class="shop-order-list-col3"><span>` + val + `</span><div class="shop-order-list-col3-img"><span></span><img src="` + romObj.goodsImg + `"></div></div>`
            }
        },
        WaresQty: {
            cnName: '<p class="shop-all-header-item">品名</p>',
            index: 2,
            width: '204px',
            converter: function (val) {
                return `<div class="shop-order-list-col4"><span>` + val + `</span><div class="shop-order-list-col4-name"><span></span><div class="shop-order-list-col4-name-in">` + val + `</div></div></div>`
            }
        },
        CreatedTimeString: {
            cnName: '<p class="shop-all-header-item">规格</p>',
            index: 3,
            width: '86px',
        },
        ReceiverName: {
            cnName: '<p class="shop-all-header-item">数量</p>',
            index: 4,
            width: '65px'
        },
        BuyerNick: {
            cnName: '<p class="shop-all-header-item">实付</p>',
            index: 5,
            width: '72px'
        },
        BuyerMessage: {
            cnName: '<p class="shop-all-header-item">订单状态</p>',
            index: 6,
            width: '87px'
        },
        ShopMessage: {
            cnName: '<p class="shop-all-header-item">物流状态</p>',
            index: 7,
            width: '103px',
            converter: function (val) {
                return `<div class="shop-order-list-col9"> 
            <span>`+ val + `</span>
            <div class="shop-logistics-details"><div class="shop-angle"></div><div class="shop-header"><span>圆通快递</span><span>运单号:</span><span>5448484646486484848</span></div><div class="shop-main"><div class="shop-item shop-item-s"><p>您已在南京新城金郡北门丰巢快递柜完成取件，感谢使用，期待再次为您服务。</p><p>2018-10-01 14:32:43</p>
            </div><div class="shop-item"><p>您已在南京新城金郡北门丰巢快递柜完成取件，感谢使用，期待再次为您服务。</p><p>2018-10-01 14:32:43</p></div><p><a href="#">...查看全部</a></p><div class="shop-item"><p>您已在南京新城金郡北门丰巢快递柜完成取件，感谢使用，期待再次为您服务。</p><p>2018-10-01 14:32:43</p></div></div></div>
            </div>`
            }

        },
        ID: {
            cnName: '<p class="shop-all-header-item">操作</p>',
            index: 8,
            width: '86px',
            converter: function (val) {
                return `<button class="shop-refund-button">退款</button>`
            }
        }
    });

}

























// 全部订单表格生成函数
function AllDatainit(data) {
    Controller.GridControl.Bind(data, ".shop-all-order-list", {
        OrderNumber: {
            cnName: '<p class="shop-all-header-item shop-order-list-col1">交易号</p>',
            index: 0,
            width: '114px',
            converter: function (val, romObj) {
                return `<div class="shop-order-list-col1">` + val + `</div>`
            }
        },
        WaresCount: {
            cnName: '<p class="shop-all-header-item">订单号</p>',
            index: 1,
            width: '124px',
            converter: function (val, romObj) {
                return `<div class="shop-order-list-col3"><span>` + val + `</span><div class="shop-order-list-col3-img"><span></span><img src="` + romObj.goodsImg + `"></div></div>`
            }
        },
        WaresQty: {
            cnName: '<p class="shop-all-header-item">品名</p>',
            index: 2,
            width: '204px',
            converter: function (val) {
                return `<div class="shop-order-list-col4"><span>` + val + `</span><div class="shop-order-list-col4-name"><span></span><div class="shop-order-list-col4-name-in">` + val + `</div></div></div>`
            }
        },
        CreatedTimeString: {
            cnName: '<p class="shop-all-header-item">规格</p>',
            index: 3,
            width: '86px',
        },
        ReceiverName: {
            cnName: '<p class="shop-all-header-item">数量</p>',
            index: 4,
            width: '65px'
        },
        BuyerNick: {
            cnName: '<p class="shop-all-header-item">实付</p>',
            index: 5,
            width: '72px'
        },
        BuyerMessage: {
            cnName: '<p class="shop-all-header-item">订单状态</p>',
            index: 6,
            width: '87px'
        },
        ShopMessage: {
            cnName: '<p class="shop-all-header-item">物流状态</p>',
            index: 7,
            width: '103px',
            converter: function (val) {
                return `<div class="shop-order-list-col9"> 
            <span>`+ val + `</span>
            <div class="shop-logistics-details"><div class="shop-angle"></div><div class="shop-header"><span>圆通快递</span><span>运单号:</span><span>5448484646486484848</span></div><div class="shop-main"><div class="shop-item shop-item-s"><p>您已在南京新城金郡北门丰巢快递柜完成取件，感谢使用，期待再次为您服务。</p><p>2018-10-01 14:32:43</p>
            </div><div class="shop-item"><p>您已在南京新城金郡北门丰巢快递柜完成取件，感谢使用，期待再次为您服务。</p><p>2018-10-01 14:32:43</p></div><p><a href="#">...查看全部</a></p><div class="shop-item"><p>您已在南京新城金郡北门丰巢快递柜完成取件，感谢使用，期待再次为您服务。</p><p>2018-10-01 14:32:43</p></div></div></div>
            </div>`
            }

        },
        ID: {
            cnName: '<p class="shop-all-header-item">操作</p>',
            index: 8,
            width: '86px'
        }
    });

}